package cn.wolfcode.web.controller;

import cn.wolfcode.domain.Permission;
import cn.wolfcode.qo.QueryObject;
import cn.wolfcode.service.IPermissionService;
import cn.wolfcode.util.RequiredPermission;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/permission")
public class PermissionController {

    @Autowired
    private IPermissionService permissionService;

    @RequiredPermission(name="权限列表",expression="permission:list")
    @RequestMapping("/list")
    public String list(Model model, QueryObject qo){
        PageInfo<Permission> pageInfo = permissionService.query(qo);
        //System.out.println(permissions);
        //key-value
        model.addAttribute("pageInfo",pageInfo);
        return "/permission/list";
    }
    @RequestMapping("/reload")
    public String reload(){
        permissionService.reload();
        return "redirect:/permission/list";
    }

}
